﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Negocio.ServerTimeService;
using System.ServiceModel;

namespace Util
{
    public class TimeManager
    {
        private static TimeManager instancia = new TimeManager();

        private TimeManager() : base() { }

        public static TimeManager ObtenerInstancia()
        {
            return instancia;
        }


        public DateTime ObtenerHoraActual()
        {
            DateTime actual;
            try
            {
                ServerTimeSoapClient webService = new ServerTimeSoapClient();
                string fecha = webService.GetDateTime();
                actual = Convert.ToDateTime(fecha);
            }
            catch (EndpointNotFoundException)
            {
                actual = DateTime.Now;
            }
            return actual;
        }
    }
}
